using System;
using System.Collections.Generic;
using System.Text;

namespace GameLib.Utils.Pathing
{

    public enum TrackState
    {
        None,
        Opened,
        Closed,
    }

    public class Track<NodeType> : IComparable< Track<NodeType> >
    {
        //private static NodeType _Target = null;
        //private static double _Coeff = 0.5;
        //private static Heuristic _ChoosenHeuristic = AStar.EuclidianHeuristic;

        //public static NodeType Target { set { _Target = value; } get { return _Target; } }

        public NodeType EndNode;
        public Track<NodeType> PrevTrack;

        public TrackState State;
/*
        public static double DijkstraHeuristicBalance
        {
            get { return _Coeff; }
            set
            {
                if (value < 0 || value > 1) throw new ArgumentException(
  @"The coefficient which balances the respective influences of Dijkstra and the Heuristic must belong to [0; 1].
-> 0 will minimize the number of nodes explored but will not take the real cost into account.
-> 0.5 will minimize the cost without developing more nodes than necessary.
-> 1 will only consider the real cost without estimating the remaining cost.");
                _Coeff = value;
            }
        }

        public static Heuristic ChoosenHeuristic
        {
            set { _ChoosenHeuristic = value; }
            get { return _ChoosenHeuristic; }
        }

        private int _NbArcsVisited;
        public int NbArcsVisited { get { return _NbArcsVisited; } }*/

        private float m_MoveCost;
        public float MoveCost 
        { 
            get { return m_MoveCost; } 
            set
            {
                m_MoveCost = value;
            }
        }


        private float m_HeuristicCost;

        public float HeuristicCost
        {
            get { return m_HeuristicCost; }
            set { m_HeuristicCost = value; }
        }

        public float Evaluation
        {
            get { return MoveCost + HeuristicCost; }
        }

        /*
        virtual public double Evaluation
        {
            get
            {
                return _Coeff * _Cost + (1 - _Coeff) * _ChoosenHeuristic(EndNode, _Target);
            }
        }*/

        //public bool Succeed { get { return EndNode == _Target; } }


        public Track(NodeType firstNode)
            : this(null, firstNode)
        {
        }

        public Track(Track<NodeType> prevTrack, NodeType nextNode)
        {
            //if (_Target == null) throw new InvalidOperationException("You must specify a target Node for the Track class.");
            PrevTrack = prevTrack;
            EndNode = nextNode;
        }

        /*
        public int CompareTo(object Objet)
        {
            Track OtherTrack = (Track)Objet;
            return Evaluation.CompareTo(OtherTrack.Evaluation);
        }

        public static bool SameEndNode(object O1, object O2)
        {
            Track P1 = O1 as Track;
            Track P2 = O2 as Track;
            if (P1 == null || P2 == null) throw new ArgumentException("Objects must be of 'Track' type.");
            return P1.EndNode == P2.EndNode;
        }*/

        #region IComparable<Track<NodeType>> Members

        public int CompareTo(Track<NodeType> other)
        {
            return Evaluation.CompareTo(other.Evaluation);
        }

        #endregion
    }
}
